home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 23.zip
/
BS1 part 23
/
Hisoft Basic v1.03 disk 2.adf
/
graphics
/
sdm.bas
< prev
next >
Wrap
BASIC Source File
|
1988-12-19
|
10KB
|
441 lines
Setup:
DIM Number$(58),Desc$(58),Value$(58)
DIM Array$(50),Array(50)
FOR x=1 TO 58
IF x>4 AND x<55 THEN Number$(x)=STR$(x-4)
NEXT x
TopLine=1
Colors=3
SCREEN 4,640,200,Colors,2
WINDOW 5,"Graphics",,20,4
PALETTE 7,.8,.2,.1
WINDOW 1,"Statistical-Data-Manager",(0,12)-(631,111),22,-1
MENU 1,0,1,"Data "
MENU 1,1,1,"Load "
MENU 1,2,1,"Save "
MENU 1,3,1,"Print "
MENU 1,4,1,"Delete"
MENU 1,5,1,"Quit "
MENU 2,0,1,"Graphics"
MENU 2,1,1,"Bar Graph"
MENU 2,2,1,"Pie Chart"
MENU 2,3,1,"Save Pic"
MENU 3,0,0,""
MENU 4,0,0,""
ON MENU GOSUB MenuControl
MENU ON
GOTO MainLoop
MenuControl:
Men=MENU(0) : MenuPoint=MENU(1)
IF Men=1 THEN
IF MenuPoint=1 THEN GOSUB LoadData
IF MenuPoint=2 THEN GOSUB SaveData
IF MenuPoint=3 THEN GOSUB PrintData
IF MenuPoint=4 THEN GOSUB ClearData
IF MenuPoint=5 THEN Quit
END IF
IF Men=2 THEN
IF MenuPoint=3 THEN
MENU 1,0,0: MENU 2,0,0
MENU OFF
GOSUB EnterName
WINDOW 5
PicSave Nam$,5,0
WINDOW 1
MENU ON
MENU 1,0,1 : MENU 2,0,1
END IF
IF MenuPoint=1 THEN Array$(0)="B"
IF MenuPoint=2 THEN Array$(0)="P"
Array(0)=TopLine
IF Value$(Array(0)+4)="" THEN Array(0)=Array(0)-1
FOR x=1 TO Array(0)
Array$(x)=Desc$(x+4)
Array(x)=VAL(Value$(x+4))
IF Array(x)=0 THEN Array(x)=.01
NEXT x
MENU OFF
MENU 1,0,0 : MENU 2,0,0
WINDOW 5 : CLS
GOSUB Graphics
WINDOW 2,"Please press a key!",(350,0)-(631,0),20,4
COLOR 0,1 : CLS
WHILE INKEY$=""
WEND
WINDOW CLOSE 2
WINDOW 1
MENU ON
MENU 1,0,1 : MENU 2,0,1
END IF
RETURN
MainLoop:
CLS
IF TopLine>50 THEN TopLine=50
IF LineOne>TopLine THEN LineOne=TopLine : BEEP
IF LineOne<1 THEN LineOne=1 : BEEP
PRINT "Number";TAB(10);"Description";TAB(45);"Value"
FOR x=LineOne TO LineOne+8
COLOR 1,0
PRINT Number$(x);TAB(10);Desc$(x);TAB(45);Value$(x)
NEXT x
IF DescData=0 THEN StartSlice=10 : EndSlice=40
IF DescData=1 THEN StartSlice=45 : EndSlice=55
xp=StartSlice
GOSUB EnterText
in$=""
GOTO MainLoop
EnterText:
IF xp<StartSlice THEN xp=StartSlice
LOCATE 6,xp
COLOR 0,3 : PRINT " "; : COLOR 1,0
i$=INKEY$
IF i$="" THEN EnterText
IF i$=CHR$(2) THEN LineOne=1 : RETURN
IF i$=CHR$(5) THEN LineOne=TopLine : RETURN
IF i$=CHR$(4) THEN DeleteLine : RETURN
IF i$=CHR$(14) THEN InsertLine : RETURN
IF i$=CHR$(28) THEN GOSUB AcceptText : xp=StartSlice : LineOne=LineOne-1: RETURN
IF i$=CHR$(29) THEN GOSUB AcceptText : xp=StartSlice : LineOne=LineOne+1: RETURN
TextPos=xp-StartSlice+1
IF DescData=0 THEN Text$=Desc$(LineOne+4)
IF DescData=1 THEN Text$=Value$(LineOne+4)
IF i$=CHR$(30) THEN
IF TextPos<=LEN(Text$) THEN i$=MID$(Text$,TextPos,1)
END IF
IF i$=CHR$(13) OR i$=CHR$(9) THEN
GOSUB AcceptText
DescData=1-DescData
IF DescData=0 THEN LineOne=LineOne+1
xp=StartSlice
IF TopLine<LineOne THEN TopLine=LineOne
RETURN
END IF
IF i$=CHR$(8) OR i$=CHR$(31) THEN
LOCATE 6,xp
IF TextPos<=LEN(Text$) THEN
PRINT RIGHT$(Text$,LEN(Text$)-TextPos+1);
ELSE
PRINT " ";
END IF
xp=xp-1 : IF xp<StartSlice THEN xp=StartSlice : BEEP : GOTO EnterText
in$=LEFT$(in$,(LEN(in$)-1))
GOTO EnterText
END IF
IF i$=CHR$(34) THEN i$=CHR$(39)
IF i$ > CHR$(31) AND i$ < CHR$(127) THEN
IF xp>=EndSlice THEN xp=EndSlice : BEEP : GOTO EnterText
LOCATE 6,xp
PRINT i$;
in$=in$+i$
xp=xp+1
END IF
GOTO EnterText
AcceptText:
IF in$<>"" THEN
IF DescData=0 THEN Desc$(LineOne+4)=in$
IF DescData=1 THEN Value$(LineOne+4)=in$
in$=""
AltData=1
END IF
RETURN
DeleteLine:
FOR x=LineOne+4 TO 54
Desc$(x)=Desc$(x+1)
Value$(x)=Value$(x+1)
NEXT x
TopLine=TopLine-1
IF TopLine<1 THEN TopLine=1
RETURN
InsertLine:
IF TopLine>=50 THEN BEEP : RETURN
FOR x=TopLine+4 TO LineOne+4 STEP -1
Desc$(x+1)=Desc$(x)
Value$(x+1)=Value$(x)
NEXT x
Desc$(LineOne+4)=""
Value$(LineOne+4)=""
TopLine=TopLine+1
RETURN
SaveData:
MENU 1,0,0 : MENU 2,0,0
MENU OFF
GOSUB EnterName
WINDOW 1
IF Nam$="" THEN EndSave
OPEN Nam$ FOR OUTPUT AS 1
PRINT #1,TopLine+4
FOR x=1 TO TopLine+4
WRITE #1,Desc$(x)
WRITE #1,Value$(x)
NEXT x
CLOSE 1
EndSave:
MENU 1,0,1 : MENU 2,0,1
MENU ON
AltData=0
RETURN
LoadData:
IF AltData=1 THEN GOSUB Query
MENU 1,0,0 : MENU 2,0,0
MENU OFF
GOSUB EnterName
WINDOW 1
IF Nam$="" THEN EndLoad
FOR x=1 TO 58
Desc$(x)=""
Value$(x)=""
NEXT x
OPEN Nam$ FOR INPUT AS 1
INPUT #1,NmbrData
TopLine=NmbrData-4
FOR x=1 TO NmbrData
INPUT #1,Desc$(x)
INPUT #1,Value$(x)
NEXT x
LineOne=TopLine
CLOSE 1
EndLoad:
WINDOW 1
COLOR 1,0
CLS
PRINT "Number";TAB(10);"Description";TAB(45);"Array"
FOR x=LineOne TO LineOne+8
PRINT Number$(x);TAB(10);Desc$(x);TAB(45);Value$(x)
NEXT x
MENU 1,0,1 : MENU 2,0,1
MENU ON
AltData=0
RETURN
EnterName:
Altname$=Nam$
WINDOW 2,"Enter filename:",(50,80)-(580,88),0,-1
CLS
LINE INPUT Nam$
IF Nam$= "=" OR Nam$="*" THEN Nam$=Altname$
WINDOW CLOSE 2
RETURN
PrintData:
MENU 1,0,0 : MENU 2,0,0
MENU OFF
OPEN "PRT:" FOR OUTPUT AS 1
PRINT #1,"File:";Altname$;CHR$(10)
PRINT #1,"Number";TAB(10);"Description";TAB(45);"Value"
FOR x=4 TO TopLine+4
PRINT #1, Number$(x);TAB(10);Desc$(x);TAB(45);Value$(x)
NEXT x
CLOSE 1
MENU 1,0,1 : MENU 2,0,1
MENU ON
RETURN
Query:
WINDOW 2,"Attention!",(155,50)-(475,135),0,-1
COLOR 0,1
CLS
LOCATE 2,3
PRINT " Your data has not"
PRINT " yet been saved."
PRINT : PRINT " Save it now?"
LOCATE 8,12 : PRINT "Yes"
LOCATE 8,21 : PRINT "No"
LINE (95,57)-(148,74),0,b
LINE (183,57)-(236,74),0,b
BEEP
WaitforMouse:
Test=MOUSE(0)
WHILE MOUSE(0)=0
WEND
x=MOUSE(1) : y=MOUSE(2)
IF 95<x AND x<148 AND 57<y AND y<74 THEN
PAINT (97,59),3,0
GOSUB SaveData
PAINT (97,59),1,0
WINDOW CLOSE 2
RETURN
END IF
IF 183<x AND x<236 AND 57<y AND y<74 THEN
PAINT (185,59),3,0
WINDOW CLOSE 2
RETURN
END IF
GOTO WaitforMouse
ClearData:
IF AltData=1 THEN GOSUB Query
RUN
Quit:
IF AltData=1 THEN GOSUB Query
COLOR 1,0
MENU RESET
CLS
END
Graphics:
IF Array(0)=0 THEN RETURN
IF UCASE$(Array$(0))="B" THEN GOSUB BarGraph
IF UCASE$(Array$(0))="P" THEN GOSUB PieChart
RETURN
PieChart:
Total=0
FOR x=1 TO Array(0)
Total=Total+Array(x)
NEXT x
Divi=Total/6.283 : Angle1=.02 : BColor=1
FOR x=1 TO Array(0)
LColor=BColor
IF LColor>(2^Colors)-1 THEN LColor=1
BColor=LColor+1
IF BColor>(2^Colors)-1 THEN BColor=1
Angle2=Angle1+Array(x)/Divi
CIRCLE (320,100),156,BColor
CIRCLE (320,100),150,BColor,-Angle2,-Angle1
PAINT (320,32),LColor,BColor
CIRCLE (320,100),150,BColor
PAINT (320,32),0,BColor
CIRCLE (320,100),150,BColor,-Angle1,-Angle2
MidAngle=(Angle1+Angle2)/2
px=320+165*COS(MidAngle)
py=100-80*SIN(MidAngle)
Distance=0
IF MidAngle>1.57 AND MidAngle<4.72 THEN Distance=LEN(Array$(x))
IF Distance>15 THEN Distance=15
COLOR LColor,0
LOCATE (py/9.25)+1,(px/9.95)+1-Distance
PRINT Array$(x);
Angle1=Angle2
NEXT x
CIRCLE (320,100),156,0
RETURN
BarGraph:
Max=.0001 : LColor=0
FOR x=1 TO Array(0)
IF Array(x)>Max THEN Max=Array(x)
NEXT x
BarWidth=INT(550/(Array(0)))
IF BarWidth>100 THEN BarWidth=100
Factor=160/Max
LOCATE 1,1 : PRINT Max;
LOCATE 10,1 : PRINT Max/2;
FOR x=0 TO 10
LINE (1,170-x*16)-(5,170-x*16)
NEXT x
FOR x=1 TO Array(0)
LColor=LColor+1 : IF LColor>(2^Colors)-1 THEN LColor=1
LINE (30+(x-1)*BarWidth,170-Array(x)*Factor)-(25+x*BarWidth,170),LColor,bf
COLOR LColor,0
LOCATE 20,(4+(x-1)*(BarWidth/9.9))
PRINT Array$(x);
NEXT x
RETURN
SUB PicSave (Nam$,WindowNr%,ArrayYN%) STATIC
IF ArrayYN%=1 THEN SHARED Colors%()
IF ArrayYN%=0 THEN
IF Colors%(0,0)<>2 THEN ERASE Colors% : DIM Colors%(31,2)
RESTORE ColorTable
FOR x=0 TO 31
READ Colors%(x,0),Colors%(x,1),Colors%(x,2)
NEXT x
ColorTable:
DATA 2,3,10, 15,15,15, 0,0,0, 15,8,0
DATA 0,0,15, 15,0,15, 0,15,15, 15,15,15
DATA 6,1,1, 14,5,0, 8,15,0, 14,11,0
DATA 5,5,15, 9,0,15, 0,15,9, 12,12,12
DATA 0,0,0, 13,0,0, 0,0,0, 15,12,10
DATA 4,4,4, 5,5,5, 6,6,6, 7,7,7
DATA 8,8,8, 9,9,9, 10,10,10, 11,11,11
DATA 12,12,12, 13,13,13, 14,14,14, 15,15,15
END IF
IF Nam$="" THEN EXIT SUB
AltWindowNr=WINDOW(1)
WINDOW WindowNr%
Wide=WINDOW(2)
IF Wide>320 THEN
Wide=640
Resolution=2
Planes=16000
ELSE
Wide=320
Resolution=1
Planes=8000
END IF
Height=WINDOW(3)
IF Height>200 THEN
Height=400
Planes=Planes*2
Resolution=Resolution+2
ELSE
Height=200
END IF
Colors=LOG(WINDOW(6)+1)/LOG(2)
OPEN Nam$ FOR OUTPUT AS 1 LEN=FRE(0)-500
PRINT #1,"FORM";
PRINT #1,MKL$(156+Planes*Colors);
PRINT #1,"ILBM";
PRINT #1,"BMHD";MKL$(20);
PRINT #1,MKI$(Wide);MKI$(Height);
PRINT #1,MKL$(0);
PRINT #1,CHR$(Colors);
PRINT #1,CHR$(0);MKI$(0);MKI$(0);
PRINT #1,CHR$(10);CHR$(11);
PRINT #1,MKI$(Wide);MKI$(Height);
PRINT #1,"CMAP";MKL$(96);
FOR x=0 TO 31
PRINT #1,CHR$(Colors%(x,0)*16);
PRINT #1,CHR$(Colors%(x,1)*16);
PRINT #1,CHR$(Colors%(x,2)*16);
NEXT x
PRINT #1,"BODY";MKL$(Planes*Colors);
Addr=PEEKL(WINDOW(8)+4)+8
FOR x=0 TO Colors-1
PlaneAddr(x)=PEEKL(Addr+4*x)
NEXT x
FOR y1=0 TO Height-1
FOR b=0 TO Colors-1
FOR x1=0 TO (Wide/32)-1
PRINT#1,MKL$(PEEKL(PlaneAddr(b)+4*x1+(Wide/8)*y1));
NEXT x1
NEXT b
PAddr=PlaneAddr(0)+(Wide/8)*y1
POKE PAddr,PEEK(PAddr) AND 63
POKE PAddr+Wide/8-1,PEEK(PAddr+Wide/8-1) AND 252
NEXT y1
PRINT #1,"CAMG";MKL$(4);
PRINT #1,MKL$(16384);
CLOSE 1
WINDOW AltWindowNr
END SUB